Skip to content

Conversation

@roomote
Copy link
Contributor

@roomote roomote bot commented Sep 11, 2025

Summary

This PR adds support for custom base URLs in the VertexAI provider, enabling users to proxy LLM API calls through an API gateway for per-user virtual API keys and usage reporting.

Changes

  • Added vertexBaseUrl field to provider settings schema
  • Updated VertexHandler to use custom base URL via GeminiHandler
  • Updated AnthropicVertexHandler to support custom base URL
  • Added UI checkbox and input field for custom base URL in Vertex.tsx component
  • Added comprehensive tests for the new functionality

Testing

  • ✅ All existing tests pass
  • ✅ New tests added for custom base URL functionality
  • ✅ Tested with both Gemini and Claude models on VertexAI

Screenshots

The UI now includes a checkbox to enable custom base URL with an input field (similar to OpenAI and other providers):

Expected UI

Fixes #7899


Important

Adds custom base URL support for VertexAI provider, updating schema, handlers, UI, and tests.

  • Behavior:
    • Adds vertexBaseUrl to vertexSchema in provider-settings.ts for custom base URL support.
    • Updates AnthropicVertexHandler and GeminiHandler to use custom base URL if provided.
    • UI in Vertex.tsx now includes a checkbox and input for custom base URL.
  • Testing:
    • Adds tests in anthropic-vertex.spec.ts and vertex.spec.ts to verify custom base URL functionality.
    • Tests cover scenarios with JSON credentials, key file, and without credentials.
  • Misc:
    • Updates GeminiHandler and AnthropicVertexHandler constructors to handle vertexBaseUrl.

This description was created by Ellipsis for 1698100. You can customize this summary. It will automatically update as commits are pushed.

- Add vertexBaseUrl field to provider settings schema
- Update VertexHandler to use custom base URL via GeminiHandler
- Update AnthropicVertexHandler to use custom base URL
- Add UI checkbox and input field for custom base URL in Vertex.tsx
- Add comprehensive tests for the new functionality

Fixes #7899
@roomote roomote bot requested review from cte, jr and mrubens as code owners September 11, 2025 13:45
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. enhancement New feature or request labels Sep 11, 2025

// Use vertexBaseUrl if this is a Vertex handler, otherwise use googleGeminiBaseUrl
const baseUrl =
this.constructor.name === "VertexHandler" ? this.options.vertexBaseUrl : this.options.googleGeminiBaseUrl
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using this.constructor.name === "VertexHandler" to detect a Vertex handler is brittle (e.g. it may break under minification). Consider using the provided isVertex flag (or another dedicated property) to decide which base URL to use.

tools.push({ googleSearch: {} })
}

// Use vertexBaseUrl if this is a Vertex handler, otherwise use googleGeminiBaseUrl
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same base URL selection logic is repeated in both createMessage and completePrompt. Consider refactoring this logic into a shared helper to reduce duplication.

@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Sep 11, 2025
Copy link
Contributor Author

@roomote roomote bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewing my own code is like debugging in production - technically possible but morally questionable.

@daniel-lxs daniel-lxs moved this from Triage to PR [Needs Prelim Review] in Roo Code Roadmap Sep 12, 2025
@hannesrudolph hannesrudolph added PR - Needs Preliminary Review and removed Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. labels Sep 12, 2025
- Replace 'any' type with proper VertexOptions type in anthropic-vertex.ts
- Use isVertex property instead of fragile constructor.name comparison in gemini.ts
- Improve test assertions clarity by checking undefined explicitly
@daniel-lxs
Copy link
Member

This doesn't seem to be working, I can't see the Custom URL field

@daniel-lxs daniel-lxs closed this Sep 12, 2025
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Sep 12, 2025
@github-project-automation github-project-automation bot moved this from PR [Needs Prelim Review] to Done in Roo Code Roadmap Sep 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request PR - Needs Preliminary Review size:L This PR changes 100-499 lines, ignoring generated files.

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Add custom base URL for Google VertexAI provider

4 participants